package com.zjsd.sqeybusiness.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zjsd.sqeybusiness.domain.Orderinfo;
import com.zjsd.sqeybusiness.service.IOrderinfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 接单信息Controller
 *
 * @author Zheng
 * @date 2025-03-10
 */
@RestController
@RequestMapping("/sqeybusiness/orderinfo")
public class OrderinfoController extends BaseController
{
    @Autowired
    private IOrderinfoService orderinfoService;

    /**
     * 查询接单信息列表
     */
    @PreAuthorize("@ss.hasPermi('sqeybusiness:orderinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(Orderinfo orderinfo)
    {
        startPage();
        List<Orderinfo> list = orderinfoService.selectOrderinfoList(orderinfo);
        return getDataTable(list);
    }

    /**
     * 导出接单信息列表
     */
    @PreAuthorize("@ss.hasPermi('sqeybusiness:orderinfo:export')")
    //@Log(title = "接单信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Orderinfo orderinfo)
    {
        List<Orderinfo> list = orderinfoService.selectOrderinfoList(orderinfo);
        ExcelUtil<Orderinfo> util = new ExcelUtil<Orderinfo>(Orderinfo.class);
        return util.exportExcel(list, "orderinfo");
    }

    /**
     * 获取接单信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('sqeybusiness:orderinfo:query')")
    @GetMapping(value = "/{orderid}")
    public AjaxResult getInfo(@PathVariable("orderid") Long orderid)
    {
        return AjaxResult.success(orderinfoService.selectOrderinfoById(orderid));
    }

    /**
     * 新增接单信息
     */
    @PreAuthorize("@ss.hasPermi('sqeybusiness:orderinfo:add')")
    //@Log(title = "接单信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Orderinfo orderinfo)
    {
        return toAjax(orderinfoService.insertOrderinfo(orderinfo));
    }

    /**
     * 修改接单信息
     */
    @PreAuthorize("@ss.hasPermi('sqeybusiness:orderinfo:edit')")
    //@Log(title = "接单信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Orderinfo orderinfo)
    {
        return toAjax(orderinfoService.updateOrderinfo(orderinfo));
    }

    /**
     * 删除接单信息
     */
    @PreAuthorize("@ss.hasPermi('sqeybusiness:orderinfo:remove')")
    //@Log(title = "接单信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderids}")
    public AjaxResult remove(@PathVariable Long[] orderids)
    {
        return toAjax(orderinfoService.deleteOrderinfoByIds(orderids));
    }
}
